<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://www.springframework.org/tags/form"  prefix="sf"%>

<c:set var="ctx" value="${pageContext.request.contextPath }" />
<link rel="stylesheet"
	href="${ctx }/resources/js/select2/select2.min.css" />
<script type="text/javascript"
	src="${ctx }/resources/js/select2/select2.min.js"></script>
<script type="text/javascript"
	src="${ctx }/resources/js/select2/zh-CN.js"></script>
<script type="text/javascript">

	$(function() {
		webside.form.series.validateSeriesForm();
	})
</script>

<%-- <script src="${basePath}/script/ajaxfileupload.js" type="text/javascript"></script>
  --%>

<script src="${ctx }/resources/js/upload/ajaxfileupload.js"
	type="text/javascript">
</script>
<script type="text/javascript">

function limitChars(){  
    var obj = document.getElementById("#summary");  
    if (obj.value.length >1000){  
        obj.value = obj.value.substr(0, 1000);  
    }  
} 

/* function textup()   
{   
var s = document.getElementById('summary').value;   
//判断ID为text的文本区域字数是否超过1000个   
if(s.length >1000)    
{   
document.getElementById('summary').value=s.substring(0,1000);   
}   
}   */
     
	function doSaveCover() {
		var fileName = $("#cover").val();
		var type = fileName.split(".");
		var ftype = type[type.length - 1]; //获取文件后缀
		$.ajaxFileUpload({
			url :'${ctx }/files/upload/' + ftype,
			secureuri : false, //是否需要安全协议，一般设置为false
			fileElementId : [ 'cover' ], //文件上传域的ID
			dataType : 'json', //返回值类型 一般设置为json
			success : function(data, status) //服务器成功响应处理函数
			{ 

				if (data.result == 0) {
					var fileId = data.data[0].id;
					var filePath = '/files/view/jpg/' + fileId;
					$("#hiddenCover").val(filePath);
					//显示图片
					$("#imgCover").attr("src",'${ctx}/files/view/jpg/' + fileId);
					//显示名字
					$("#labcover").html(data.data[0].name);
					
				}
			},
			error : function(data, status, e) //服务器响应失败处理函数
			{
				alert(e);
			}
		});
		
	}

	
	function doSavePoster() {
		var fileName = $("#poster").val();
		var type = fileName.split(".");
		var ftype = type[type.length - 1]; //获取文件后缀
		 
		$.ajaxFileUpload({
			url :'${ctx}/files/upload/' + ftype,
			secureuri : false, //是否需要安全协议，一般设置为false
			fileElementId : [ 'poster' ], //文件上传域的ID
			dataType : 'json', //返回值类型 一般设置为json
			success : function(data, status) //服务器成功响应处理函数
			{ 
				 
				if (data.result == 0) {
					var fileId = data.data[0].id;
					var filePath = '/files/view/jpg/' + fileId;
					$("#hiddenPoster").val(filePath);
					//显示图片
					$("#imgPoster").attr("src",'${ctx }/files/view/jpg/' + fileId);
					//显示名字
					$("#laPoster").html(data.data[0].name);
				}
			},
			error : function(data, status, e) //服务器响应失败处理函数
			{
				alert(e);
			}
		});
	}
	/* function logoUploadComplete(path) {
	 $('#LogoPath').val(path);
	 var Img = document.createElement("img");
	 Img.src = path;
	 document.getElementById("ChooseLogo").innerHTML = Img.outerHTML;
	 };
	 */
 
	/*二级联动  */
	$(function() {
		$("#channel").change(
		function() {
			$("#type option[value!='']").remove();
			$.post("series/getDramaTypes.html?code="
					+ $("#channel").val(), function(data, textStatus) {
				var dataObj = eval("(" + data + ")");
				for (var i = 0; i < dataObj.length; i++) {
					var $option = $("<option></option>");
					$option.attr("value", dataObj[i].code);
					$option.text(dataObj[i].name);
					$("#type").append($option);
					
				}
			});
			$("#kind option[value!='']").remove();
			$.post("series/getSerieKinds.html?code=" + $("#channel").val(),
					function(data, textStatus) {
						var dataObj = eval("(" + data + ")");
						for (var i = 0; i < dataObj.length; i++) {
							var $option = $("<option></option>");
							$option.attr("value", dataObj[i].code);
							$option.text(dataObj[i].name);
							$("#kind").append($option);
						}
					});
		});
		$("#type").change(
		function() {
			$("#typeName").val($("#type").find("option:selected").text());
		});
		$("#kind").change(
				function() {
					 
					$("#kindName").val($("#kind").find("option:selected").text());
				});		
	});
</script>

<div class="page-header">
	<h1>
		<c:if test="${empty seriesEntity}">
		新增视频
		</c:if>
		<c:if test="${!empty seriesEntity}">
		编辑视频
		</c:if>
	</h1>
</div>
<div class="row" style="margin-top: 5px;">
	<div class="col-xs-12">
		<!--  <form action="series/addinsert.html" id="addUI" name="addUI" class="form-horizontal" role="form" method="post">-->
		<form id="seriesForm" name="seriesForm" class="form-horizontal"
			role="form" method="post">
			<c:if test="${!empty seriesEntity}">
				<input type="hidden" id="pageNum" name="pageNum"
					value="${page.pageNum }">
				<input type="hidden" id="pageSize" name="pageSize"
					value="${page.pageSize }">
				<input type="hidden" id="orderByColumn" name="orderByColumn"
					value="${page.orderByColumn }">
				<input type="hidden" id="orderByType" name="orderByType"
					value="${page.orderByType }">
				<input type="hidden" id='id' name="id" value="${seriesEntity.id }">
				<%-- <input type="hidden" id='id' name="id" value="${bvideoentity.seriesId }"> --%>
			</c:if>
			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="seoTitle">seo_title</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<input class="form-control" name="seoTitle" id="seoTitle" type="text"
							value="${seriesEntity.seoTitle }" placeholder="seo_title"  />
					</div>
				</div>
			</div>
			
			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="seoKeywords">seo_keywords</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<input class="form-control" name="seoKeywords" id="seoKeywords" type="text"
							value="${seriesEntity.seoKeywords }" placeholder="seo_keywords"  />
					</div>
				</div>
			</div>
			
			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="seoDescription">seo_description</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<input class="form-control" name="seoDescription" id="seoDescription" type="text"
							value="${seriesEntity.seoDescription }" placeholder="seo_description"  />
					</div>
				</div>
			</div>
		</form>
		<div class="hr hr-dotted"></div>
	</div>
</div>
<div class="center">
	<button id="btnAdd" type="button"
		onclick="javascript:$('#seriesForm').submit();"
		class="btn btn-success btn-sm">
		<i class="fa fa-user-plus"></i>&nbsp;
		<c:if test="${empty seriesEntity}">
		添加
		</c:if>
		<c:if test="${!empty seriesEntity}">
		保存
		</c:if>
	</button>
	<button id="btn" type="button"
		onclick="webside.common.loadPage('/series/listUI.html<c:if test="${!empty seriesEntity}">?page=${page.pageNum }&rows=${page.pageSize }&sidx=${page.orderByColumn }&sord=${page.orderByType }</c:if>')"
		class="btn btn-info btn-sm">
		<i class="fa fa-undo"></i>&nbsp;返回
	</button>
</div>